package com.ruoyi.pachong;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pachong.domain.HpageDaohang;
import com.ruoyi.pachong.service.IHpageDaohangService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 优质导航数据Controller
 * 
 * @author ruoyi
 * @date 2022-04-08
 */
@RestController
@RequestMapping("${uriconfig.managepri}/homepage/daohang")
public class HpageDaohangController extends BaseController
{
    @Autowired
    private IHpageDaohangService hpageDaohangService;

    /**
     * 查询优质导航数据列表
     */
    @PreAuthorize("@ss.hasPermi('homepage:daohang:list')")
    @GetMapping("/list")
    public TableDataInfo list(HpageDaohang hpageDaohang)
    {
        startPage();
        List<HpageDaohang> list = hpageDaohangService.selectHpageDaohangList(hpageDaohang);
        return getDataTable(list);
    }

    /**
     * 导出优质导航数据列表
     */
    @PreAuthorize("@ss.hasPermi('homepage:daohang:export')")
    @Log(title = "优质导航数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HpageDaohang hpageDaohang)
    {
        List<HpageDaohang> list = hpageDaohangService.selectHpageDaohangList(hpageDaohang);
        ExcelUtil<HpageDaohang> util = new ExcelUtil<HpageDaohang>(HpageDaohang.class);
        util.exportExcel(response, list, "优质导航数据数据");
    }

    /**
     * 获取优质导航数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('homepage:daohang:query')")
    @GetMapping(value = "/{dhId}")
    public AjaxResult getInfo(@PathVariable("dhId") Long dhId)
    {
        return AjaxResult.success(hpageDaohangService.selectHpageDaohangByDhId(dhId));
    }

    /**
     * 新增优质导航数据
     */
    @PreAuthorize("@ss.hasPermi('homepage:daohang:add')")
    @Log(title = "优质导航数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HpageDaohang hpageDaohang)
    {
        return toAjax(hpageDaohangService.insertHpageDaohang(hpageDaohang));
    }

    /**
     * 修改优质导航数据
     */
    @PreAuthorize("@ss.hasPermi('homepage:daohang:edit')")
    @Log(title = "优质导航数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HpageDaohang hpageDaohang)
    {
        return toAjax(hpageDaohangService.updateHpageDaohang(hpageDaohang));
    }

    /**
     * 删除优质导航数据
     */
    @PreAuthorize("@ss.hasPermi('homepage:daohang:remove')")
    @Log(title = "优质导航数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dhIds}")
    public AjaxResult remove(@PathVariable Long[] dhIds)
    {
        return toAjax(hpageDaohangService.deleteHpageDaohangByDhIds(dhIds));
    }
}
